package com.ete.service.dialog.log

import android.content.Context
import android.view.LayoutInflater
import com.blankj.utilcode.util.ToastUtils
import com.ete.service.dialog.BaseDialog
import com.ete.service.service.R
import com.ete.service.service.databinding.DialogInputDesQuestionBinding

/**
 * Author:LiXian
 * <p>
 * Desc:输入描述dialog
 * Version:1.0
 * date 2023/12/20 14:23
 */
class InputDescriptionDialog(mContext: Context, var mThemeColor: Int, var mCallback: (String) -> Unit)
    : BaseDialog(mContext, R.style.XUIDialog_Custom) {

    private val mBinding = DialogInputDesQuestionBinding.inflate(LayoutInflater.from(context))

    fun initDialog(inputContent: String) {
        setCanceledOnTouchOutside(false)
        setCancelable(false)
        setContentView(mBinding.root)
        mBinding.dialogBtnCancel.setOnClickListener { dismiss() }
        mBinding.dialogIvClose.setOnClickListener {
            dismiss()
        }
        mBinding.dialogBtnOk.updateThemeColor(mThemeColor)
        mBinding.dialogEtInput.setText(inputContent)
        mBinding.dialogBtnOk.setOnClickListener {
            val inputText = mBinding.dialogEtInput.text?.toString() ?: ""
            if (inputText.isEmpty()) {
                ToastUtils.showShort(R.string.upload_input_des_question)
            } else {
                mCallback.invoke(inputText)
                dismiss()
            }
        }
    }

    override fun getDialogWidthRate(): Float = 0.55F
}